<template>
  <div>
    <el-link type="primary" @click="showDetail">
      查看<i class="el-icon-view el-icon--right"></i>
    </el-link>

    <el-dialog title="查看国内仓库" :visible.sync="centerDialogVisible" width="20%">
      <el-table
        :data="tableData"
        style="width: 100%">
        <el-table-column
          prop="warehouseName"
          label="国内仓库"
          width="100">
        </el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>

<script>
  import { ajax } from "@/store/yg/common/utils";

  export default {
    props: ["row", "data", "more"],
    data() {
      return {
        centerDialogVisible: false,
        discountConfigObj: {},
        tableData: [],
      };
    },

    methods: {
      async showDetail() {
        this.centerDialogVisible = true;
        const { code, data, message } = await ajax("getSelectedWarehouseNames", {
          id: this.discountConfigObj.id
        });
        if (code === 200) {
          this.tableData = [];
          for (let item of data) {
            let obj = {};
            obj.warehouseName = item;
            this.tableData.push(obj);
          }
        } else {
          if (message) {
            this.$message.error(message);
          } else {
            this.$message.error("服务器异常");
          }
        }
      }
    },
    mounted() {
      this.discountConfigObj = this.data;
    }
  };
</script>

<style>

</style>
